package edu.zju.gis.dbfg.model.loader;

import edu.zju.gis.dbfg.model.base.BaseModelArgs;
import lombok.Getter;
import lombok.Setter;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

/**
 * @author Hu
 * @date 2019/9/28
 * LCRA 数据入库工具参数
 * 对于LCRA数据，字段根据国标是明确的，直接从Model获取
 **/
@Getter
@Setter
public class LCRALoaderArgs extends BaseModelArgs implements Serializable {

  private final static Logger logger = LoggerFactory.getLogger(LCRALoaderArgs.class);

  @Option(name = "-jobName",usage = "application name", required = true)
  private String name;

  @Option(name = "-input",usage = "输入数据文件路径", required = true)
  private String input;

  @Option(name = "-errorsOut",usage = "错误信息输出文件路径", required = true)
  private String errorOut;

  @Option(name = "-inputType",usage = "输入数据文件类型", required = false)
  private String type = "wkt";

  @Option(name = "-layername",usage = "图层名称，如果文件为shp类型的话", required = false)
  private String layerName;

  @Option(name = "-outdir",usage = "索引名称", required = true)
  private String id;

  @Option(name = "-crs",usage = "数据坐标系", required = false)
  private String crs = "EPSG:4490";

  public static LCRALoaderArgs initArgs(String args[]){
    LCRALoaderArgs mArgs = new LCRALoaderArgs();
    CmdLineParser parser = new CmdLineParser(mArgs);
    try {
      parser.parseArgument(args);
      return mArgs;
    } catch (CmdLineException e) {
      logger.error(e.getLocalizedMessage());
      return null;
    }
  }

}
